//
//  YDOAApplyPresentVC.swift
//  YDOAProduct
//
//  Created by YDWY on 2017/6/1.
//  Copyright © 2017年 Allen. All rights reserved.
//

import UIKit

class YDOAApplyPresentVC: UIViewController {

    var type : String? = ""
    var callBack : ((_ type : Int)->Swift.Void)? = nil
    
    var btnTitle : String?
    
    @IBOutlet weak var typeBtn: UIButton!//申请类型
    @IBOutlet weak var detialBtn: UIButton!    //申请详细
    @IBOutlet weak var bgView1: UIView!//紧急物资申请背景
    @IBOutlet weak var bgView2: UIView!//发起申请背景
    override func viewDidLoad() {
        super.viewDidLoad()
        setupUI()
        if type == "紧急" {
            bgView2.isHidden = true
        }else{
            bgView1.isHidden = true
        }
        
     
    }

    
    private func setupUI(){
        typeBtn.layer.borderColor = UIColor.lightGray.cgColor
        typeBtn.layer.borderWidth = 1
        detialBtn.layer.borderColor = UIColor.lightGray.cgColor
        detialBtn.layer.borderWidth = 1
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    //取消按钮点击
    @IBAction func cancel(_ sender: UIButton) {

        self.dismiss(animated: true) { 
            
        }
    }
    
    //确定按钮点击
    @IBAction func sure(_ sender: Any) {
    
        if callBack != nil {
            self.dismiss(animated: true, completion: { 
                self.callBack!(1)
            })
            
            
        }
    }
  
    //申请类型按钮点击
    @IBAction func typeBtnClick(_ sender: Any) {
        let popmenu =   YMPopMenu(frame: view.bounds, dataSource: [
                ["id":"1","item":"行政物品申请"],
                ["id":"2","item":"费用申请"],
                ["id":"3","item":"车辆申请"],
            ])
        view.addSubview(popmenu)
        weak var weakSelf = self
        popmenu.callBack = {(id : String, title : String) in
            weakSelf?.typeBtn.setTitle(title, for: .normal)
        }
        
        
    }
   
    //申请详细按钮点击
    @IBAction func detialBtnClick(_ sender: Any) {
        weak var weakSelf = self
        let popmenu =   YMPopMenu(frame: view.bounds, dataSource: [
            ["id":"1","item":"差旅公出申请"],
            ["id":"2","item":"请假申请"],
            ["id":"3","item":"物资申请"],
            ])
        view.addSubview(popmenu)
        popmenu.callBack = {(id : String, title : String) in
            weakSelf?.detialBtn.setTitle(title, for: .normal)
         
        }
    
    }

}



